package gov.pbc.nn.kjgl.item.template.handler;

import gov.pbc.nn.kjgl.item.template.dao.ItemApprovalDao;
import gov.pbc.nn.kjgl.item.template.entity.ItemApproval;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.bstek.uflo.env.Context;
import com.bstek.uflo.model.ProcessInstance;
import com.bstek.uflo.model.task.Task;
import com.bstek.uflo.process.listener.TaskListener;
import com.bstek.uflo.process.node.TaskNode;
@Component("sqbmkzsh.TaskName")
public class SqbmkzshTaskName implements TaskListener{

	@Autowired
	private ItemApprovalDao itemApprovalDao;
	
	@Override
	public boolean beforeTaskCreate(Context arg0, ProcessInstance arg1, TaskNode arg2) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void onTaskComplete(Context arg0, Task arg1) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onTaskCreate(Context context, Task task) {
		String businessId = task.getBusinessId();
		ItemApproval itemApproval = this.itemApprovalDao.get(businessId,ItemApproval.class);
		task.setTaskName("科长审核"+itemApproval.getTypeName()+"【"+itemApproval.getName()+"】");
		context.getSession().saveOrUpdate(task);
	}

}
